//
//  HJBarCodeController.m
//  newOcWeibo
//
//  Created by heJing on 15/7/21.
//  Copyright © 2015年 heima. All rights reserved.
//

#import "HJBarCodeController.h"

@interface HJBarCodeController ()
- (IBAction)close:(id)sender;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topCons;

@property(nonatomic, strong)CADisplayLink *link;
@end

@implementation HJBarCodeController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.link removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];

    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
    
    self.link = link;

}

-(void)update{
    
    self.topCons.constant -= 1;
    if (self.topCons.constant == -128) {
        self.topCons.constant = 128;
    }
}


- (IBAction)close:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
